package cn.lyjuan.android.mylibrary.frame.load.fragment;

import android.os.Bundle;

import java.io.Serializable;

import cn.lyjuan.android.mylibrary.frame.load.IOnReloadListener;
import cn.lyjuan.android.mylibrary.view.fragment.AbstractFragment;

/**
 * 提供重载监听
 * Created by chad on 14/11/2017.
 */
public abstract class AbstractLoadFailedFragment extends AbstractFragment
{
    protected IOnReloadListener onReloadListener;

    public IOnReloadListener getOnReloadListener()
    {
        return onReloadListener;
    }

    public AbstractLoadFailedFragment setOnReloadListener(IOnReloadListener onReloadListener)
    {
        this.onReloadListener = onReloadListener;
        return this;
    }

    @Override
    protected void store(Bundle ble)
    {
        if (null != onReloadListener)
            ble.putSerializable("load_listener", onReloadListener);
    }

    @Override
    protected void restore(Bundle ble)
    {
        if (null == onReloadListener)
        {
            Serializable ser = ble.getSerializable("load_listener");
            if (null != ser)
                onReloadListener = (IOnReloadListener) ser;
        }
    }
}
